﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using com.lover.astd.common.config;
using com.lover.astd.common.model;
using com.lover.astd.common;

namespace com.lover.astd.game.ui.server.impl.activities
{
    /// <summary>
    /// 古城寻宝
    /// </summary>
    class DailyTreasureGameServer : LogicServer
    {
        public DailyTreasureGameServer(MainForm frm) { _mainForm = frm; ServerName = ConfigStrings.S_Daily_Treasure_Game; ServerReadableName = ConfigStrings.SR_Daily_Treasure_Game; }
        public override void renderSettings()
        {
            MainForm frm = _mainForm;
            Dictionary<string, string> conf = getConfig(ServerName);
            frm.chk_daily_treasure_game.Checked = conf.ContainsKey(ConfigStrings.enabled) && conf[ConfigStrings.enabled].ToLower().Equals("true");
            frm.txt_daily_treasure_game_boxtype.Text = conf.ContainsKey(ConfigStrings.open_box_type) ? conf[ConfigStrings.open_box_type] : ""; ;
            frm.txt_daily_treasure_game_goldmove_boxtype.Text = conf.ContainsKey(ConfigStrings.gold_move_box_type) ? conf[ConfigStrings.gold_move_box_type] : "";
            int _minGoldSteps = 0;
            if (conf.ContainsKey(ConfigStrings.goldstep)) Int32.TryParse(conf[ConfigStrings.goldstep], out _minGoldSteps);
            frm.num_daily_treasure_game_goldstep.Value = _minGoldSteps;
        }
        public override void saveSettings()
        {
            MainForm frm = _mainForm;
            GameConfig conf = getConfig();
            conf.setConfig(ServerName, ConfigStrings.enabled, frm.chk_daily_treasure_game.Checked.ToString());
            conf.setConfig(ServerName, ConfigStrings.open_box_type, frm.txt_daily_treasure_game_boxtype.Text);
            conf.setConfig(ServerName, ConfigStrings.gold_move_box_type, frm.txt_daily_treasure_game_goldmove_boxtype.Text);
            conf.setConfig(ServerName, ConfigStrings.goldstep, frm.num_daily_treasure_game_goldstep.Value.ToString());
        }
        public override void loadDefaultSettings()
        {
            GameConfig conf = getConfig();
            conf.setConfig(ServerName, ConfigStrings.enabled, "true");
            conf.setConfig(ServerName, ConfigStrings.open_box_type, "01");
            conf.setConfig(ServerName, ConfigStrings.gold_move_box_type, "");
            conf.setConfig(ServerName, ConfigStrings.goldstep, "0");
            renderSettings();
        }
    }
}
